// component/business-farmer/index.js
Component({
    /**
     * 组件的属性列表
     */
    options: {
        styleIsolation: "shared",
    },
    properties: {
        role: {
            type: String,
            value: "",
            observer: function (value) {
                let tabList = this.data.tabList
                if (value == 2) {
                    tabList.splice(-1, 1)
                } else if (value == 3) {
                    tabList.splice(2, 1)
                }
                this.setData({
                    tabList: tabList
                })
            }
        },
    },

    /**
     * 组件的初始数据
     */
    data: {
        active: 0,
        tabList: [{
            title: "交易",
            component: "allBusiness"
        }, {
            title: "待除皮",
            component: "waitPeeling"
        }, {
            title: "待开价",
            component: "waitPricing"
        }, {
            title: "待称重",
            component: "waitWeighing"
        }]
    },

    /**
     * 组件的方法列表
     */
    methods: {
        onChange(e) {
            this.setData({
                active: e.detail.index
            })
        },
        changeTab(e) {
            this.setData({
                active: e.detail.active
            })
        },
        bookPicker(item) {
            this.triggerEvent('bookPicker', item.detail)
        },
        onPullDownRefresh() {
            const childComponent = this.selectComponent('.component');
            if (childComponent.onPullDownRefresh) {
                childComponent.onPullDownRefresh()
            } else {
                wx.stopPullDownRefresh();
            }
        },
        onReachBottom() {
            const childComponent = this.selectComponent('.component');
            childComponent.onPullDownRefresh && childComponent.onReachBottom()
        }
    }
})